function InitializeList takes hashtable list returns hashtable
	call SaveInteger(list , 0 , StringHash("SIZE") , 0)
	call SaveInteger(list , 0 , StringHash("ALLOC_ADDRESS") , 5)
	call SaveInteger(list , 0 , StringHash("NEXT_NODE_ADDRESS") , -1)
	return list
endfunction

function CreateList takes nothing returns hashtable
	return InitializeList(InitHashtable())
endfunction

function DestroyList takes hashtable list returns nothing
	call FlushParentHashtable(list)
endfunction

function ListAddNumber takes hashtable list , integer number returns nothing
	local integer newNodeAddress = LoadInteger(list , 0 , StringHash("ALLOC_ADDRESS"))
	local integer headNextAddress = LoadInteger(list , 0 , StringHash("NEXT_NODE_ADDRESS"))
	call SaveInteger(list , newNodeAddress , StringHash("VALUE") , number)
	call SaveInteger(list , newNodeAddress , StringHash("LAST_NODE_ADDRESS") , 0)
	call SaveInteger(list , newNodeAddress , StringHash("NEXT_NODE_ADDRESS") , headNextAddress)
	call SaveInteger(list , 0 , StringHash("SIZE") , LoadInteger(list , 0 , StringHash("SIZE")) + 1)
	call SaveInteger(list , 0 , StringHash("ALLOC_ADDRESS") , newNodeAddress + 1)
	call SaveInteger(list , 0 , StringHash("NEXT_NODE_ADDRESS") , newNodeAddress)
	if headNextAddress >= 0 then
		call SaveInteger(list , headNextAddress , StringHash("LAST_NODE_ADDRESS") , newNodeAddress)
	endif
endfunction

function ListRemoveNumberAddress takes hashtable list , integer address returns nothing
	local integer lastAddress = LoadInteger(list , address , StringHash("LAST_NODE_ADDRESS"))
	local integer nextAddress = LoadInteger(list , address , StringHash("NEXT_NODE_ADDRESS"))
	//--
	call BJDebugMsg("lastAddress: " + I2S(lastAddress))
	call BJDebugMsg("nextAddress: " + I2S(nextAddress))
	call SaveInteger(list , lastAddress , StringHash("NEXT_NODE_ADDRESS") , nextAddress)
	if nextAddress >= 0 then //不是尾巴
		call SaveInteger(list , nextAddress , StringHash("LAST_NODE_ADDRESS") , lastAddress)
	endif
	call SaveInteger(list , 0 , StringHash("SIZE") , LoadInteger(list , 0 , StringHash("SIZE")) - 1)
	call FlushChildHashtable(list , address)
endfunction

function GetListSize takes hashtable list returns integer
	return LoadInteger(list , 0 , StringHash("SIZE"))
endfunction

function ForList takes hashtable list , code callBack returns nothing
	local integer addressNow = 0
	local trigger executeTrigger = CreateTrigger()
	local triggeraction executeTriggerAction = TriggerAddAction(executeTrigger , callBack)
	loop
		set addressNow = LoadInteger(list , addressNow , StringHash("NEXT_NODE_ADDRESS"))
		exitwhen addressNow < 0
		set udg_TempInteger = LoadInteger(list , addressNow , StringHash("VALUE"))
		call TriggerExecute(executeTrigger)
	endloop
	call TriggerRemoveAction(executeTrigger , executeTriggerAction)
	call DestroyTrigger(executeTrigger)
	set executeTrigger = null
	set executeTriggerAction = null
endfunction